package com.estore.model;

class Product {
    private String id;
    // 其他属性，如名称、价格、描述等
    private String name;
    private double price;

    // 构造方法、getter和setter方法
    public Product(String id, String name, double price) {
        this.id = id;
        this.name = name;
        this.price = price;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    // 其他业务方法...
}
class Product implements Comparable<Product> {
    private String id;
    private String name;
    private double price;

    public Product(String id, String name, double price) {
        this.id = id;
        this.name = name;
        this.price = price;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    /**
     * 实现Comparable接口的compareTo方法，按商品ID的字母顺序升序排列
     * @param other 另一个Product对象
     * @return 负数：当前对象小于other；0：相等；正数：当前对象大于other
     */
    @Override
    public int compareTo(Product other) {
        // 调用String的compareTo方法，按字母顺序比较id
        return this.id.compareTo(other.id);
    }
}